package de.gameduell.framework.facebook.app.appevents {
	import de.gameduell.framework.facebook.app.Controller;

	import de.gameduell.framework.debug.Debug;

	import flash.events.EventDispatcher;

	public class CoinEventManager extends EventDispatcher {

		private var coinEvents:Array;
		private var controller:Controller;

		public function CoinEventManager(eventXML:XMLList) {
			coinEvents = new Array();
			controller = Controller.getInstance();
			for(var j:* in eventXML){
				var event:XML = XML(eventXML[j]);
				var aCoinEvent:CoinTriggeredAction = new CoinTriggeredAction(controller, event);
				aCoinEvent.addEventListener(CoinEvent.COIN_EVENT_STARTED, doCoinEvent);
				coinEvents.push(aCoinEvent);
			}
		}
		
		private function doCoinEvent(event:CoinEvent):void {
			Debug.trace("CoinEventManager::doCoinEvent:");
			dispatchEvent(new CoinEvent(event.type, event.coinTriggeredAction));
		}
	}
}
